#include <bits/stdc++.h>
using namespace std;
vector<int> summax(vector<int>& a, vector<int>& b)
{
    int len_a = a.size();
    int len_b = b.size();
    int minlen = len_a<len_b?len_a:len_b;
    int maxlen = len_a>len_b?len_a:len_b;
    vector<int> tackIn;
    vector<int> result;
    while(a.size()>0&&b.size()>0)
    {
        int sum;
        if(tackIn.empty())
            sum = a.back()+b.back();
        else
        {
            sum = a.back()+b.back()+tackIn.back();
            tackIn.pop_back();
        }
        a.pop_back();
        b.pop_back();
        if(sum>10){
            tackIn.push_back(1);
            sum%=10;
            result.push_back(sum);
        } else{
            result.push_back(sum);
        }
        minlen--;
    }
    vector<int> res = a.size()>0?a:b;
    while(res.size()!=0)
    {
        result.push_back(res.back());
        res.pop_back();
    }

    return result;
}
int main() {
    vector<int> a = {2,2,2,2,6};
    vector<int> b = {3,3,3,2};
    vector<int> r = summax(a,b);
    while(!r.empty())
    {
        int temp = r.back();
        cout<<temp;
        r.pop_back();
    }
    cout<<"\n";
    return 0;
}